<!--TODO:不足：到最后发现很多可以做的提升 都没做到 因为从一开始就没有规划需求
    TODO:做的太随性了，应先做好文档，再根据文档进行编程-->
<template>
  <div>
    <BlogHeader :active-index="'4'"></BlogHeader>
    <div class="main">
      <div class="infinite-list-wrapper" style="overflow:auto">

        <ul v-for="i in answers">
          <li key="i._id">
            <div class="el-table-filter__list-item">
                <div style="text-align: center">
                  第{{i.file_name}}题结果:{{questionState(i.ret)}}   判题时间:   {{new Date(i.time).toLocaleDateString()}}   {{new Date(i.time).toLocaleTimeString()}}
                </div>
            </div>
            <el-divider></el-divider>
          </li>
        </ul>

      </div>
    </div>

  </div>



</template>

<script>
import {getBlogs} from "../api/api";
import BlogHeader from "../components/BlogHeader";
export default {
  name: "AnswerList",
  components: {BlogHeader},
  data () {
    return {
      answers: [],
    }
  },

  mounted() {
    this.loadBooks()
  },

  computed: {
    noMore () {
      return !this.nextUrl
    },
    disabled () {
      return this.loading || this.noMore
    }
  },

  methods: {
    loadBooks() {
      const para = this.$route.params.username
      getBlogs('/api/answer/' + para).then(response => {
        this.answers = response.data.data.ret
        console.log(this.answers)
      })
    },

    questionState(ret) {
      switch (ret) {
        case 1:
          return "通过"
        case 2:
          return "编译错误"
        case 3:
          return "答案错误"
        case 4:
          return "超过时间限制"
        case 5:
          return "超过空间限制"
      }
    },

  },

}
</script>

<style scoped>


.title {
  color: #121212;
  text-align: center;
  text-decoration: none;
}

ul {
  margin: 0;
  padding-inline-start: 0;
}

p {
  text-align: center;
}







</style>
